<template>
    <div>
        <div class="chain-list">
            <div style="display: flex; margin-bottom: 10px;">
                <div style="padding-top: 6px;"><img src="@/assets/chain.png" alt="" width="20px" height="20px"></div>
                <div class="chain-title">业务链列表</div>
                <el-button type="primary" plain @click="addChainVisible = true">添加业务链</el-button>
            </div>
            <el-dialog title="添加业务链" :visible.sync="addChainVisible">
                <el-form :model="chainForm">
                    <!-- <el-form-item label="issuerDid" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.issuerDid" autocomplete="off"></el-input>
                    </el-form-item> -->
                    <el-form-item label="tlsHostName" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.tlsHostName" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="nodeAddress" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.nodeAddress" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="chainId" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.chainId" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="orgId" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.orgId" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="rootCaCrt" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.rootCaCrt" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="userKey" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.userKey" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="userCrt" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.userCrt" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="userSignKey" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.userSignKey" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="userSignCrt" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.userSignCrt" autocomplete="off"></el-input>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="cancelAddChain()">取 消</el-button>
                    <el-button type="primary" @click="addChain()">确 定</el-button>
                </div>
            </el-dialog>
            <el-dialog title="更新业务链信息" :visible.sync="updateChainVisible">
                <el-form :model="chainForm">
                    <!-- <el-form-item label="issuerDid" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.issuerDid" autocomplete="off"></el-input>
                    </el-form-item> -->
                    <el-form-item label="tlsHostName" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.tlsHostName" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="nodeAddress" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.nodeAddress" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="chainId" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.chainId" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="orgId" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.orgId" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="rootCaCrt" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.rootCaCrt" autocomplete="off" type="textarea"></el-input>
                    </el-form-item>
                    <el-form-item label="userKey" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.userKey" autocomplete="off" type="textarea"></el-input>
                    </el-form-item>
                    <el-form-item label="userCrt" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.userCrt" autocomplete="off" type="textarea"></el-input>
                    </el-form-item>
                    <el-form-item label="userSignKey" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.userSignKey" autocomplete="off" type="textarea"></el-input>
                    </el-form-item>
                    <el-form-item label="userSignCrt" :label-width="formLabelWidth">
                        <el-input v-model="chainForm.userSignCrt" autocomplete="off" type="textarea"></el-input>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="updateChainVisible = false">取 消</el-button>
                    <el-button type="primary" @click="updateChain()">确 定</el-button>
                </div>
            </el-dialog>
            <el-table :data="tableData" v-loading="loading" :border="true" style="width: 100%" :header-cell-style="{background:'#D8E8FF'}">
                <el-table-column type="index" label="序号" width="50" align="center" />
                <!-- <el-table-column prop="ChainDID" label="ChainDID" width="200" align="center" /> -->
                <el-table-column prop="info.ChainId" label="ChainId" width="200" align="center" />
                <el-table-column prop="info.NodeAddress" label="NodeAddress" width="240" align="center" />
                <el-table-column prop="info.OrgId" label="OrgId" width="250" align="center" />
                <el-table-column prop="info.TlsHostName" label="TlsHostName" align="center" />
                <!-- <el-table-column prop="sign" label="sign" /> -->
                <el-table-column prop="name" label="操作" width="200" align="center">
                    <template slot-scope="scope">
                        <el-button type="primary" plain @click="deleteChain(scope.$index)">移除</el-button>
                        <el-button type="primary" plain @click="updateChainShow(scope.$index)">更新</el-button>
                        <!-- <el-button type="primary" plain @click="signChainShow(scope.$index)">签名</el-button> -->
                        <!-- <el-button type="primary" plain @click="bindChainShow(scope.$index)">绑定</el-button> -->
                    </template>
                </el-table-column>
            </el-table>
        </div>
        <div class="user-chain-list">
            <div style="display: flex; margin-bottom: 10px;">
                <div style="padding-top: 6px;"><img src="@/assets/chain.png" alt="" width="20px" height="20px"></div>
                <div class="user-chain-title">用户业务链DID列表</div>
                <el-button type="primary" plain @click="addUserChainVisible = true">添加用户业务链DID</el-button>
            </div>
            <el-dialog title="添加用户业务链DID" :visible.sync="addUserChainVisible">
                <el-form :model="userChainForm">
                    <el-form-item label="issuerDid" :label-width="formLabelWidth">
                        <el-input v-model="userChainForm.issuerDid" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="tlsHostName" :label-width="formLabelWidth">
                        <el-input v-model="userChainForm.tlsHostName" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="nodeAddress" :label-width="formLabelWidth">
                        <el-input v-model="userChainForm.nodeAddress" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="chainId" :label-width="formLabelWidth">
                        <el-input v-model="userChainForm.chainId" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="orgId" :label-width="formLabelWidth">
                        <el-input v-model="userChainForm.orgId" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="rootCaCrt" :label-width="formLabelWidth">
                        <el-input v-model="userChainForm.rootCaCrt" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="userKey" :label-width="formLabelWidth">
                        <el-input v-model="userChainForm.userKey" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="userCrt" :label-width="formLabelWidth">
                        <el-input v-model="userChainForm.userCrt" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="userSignKey" :label-width="formLabelWidth">
                        <el-input v-model="userChainForm.userSignKey" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="userSignCrt" :label-width="formLabelWidth">
                        <el-input v-model="userChainForm.userSignCrt" autocomplete="off"></el-input>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="cancelAddUserChain()">取 消</el-button>
                    <el-button type="primary" @click="addUserChain()">确 定</el-button>
                </div>
            </el-dialog>
            <el-table :data="userTableData" v-loading="loading" :border="true" style="width: 100%" :header-cell-style="{background:'#D8E8FF'}">
                <el-table-column type="index" label="序号" width="50" align="center" />
                <el-table-column prop="ChainDID" label="ChainDID" width="200" align="center" />
                <el-table-column prop="info.ChainId" label="ChainId" width="200" align="center" />
                <el-table-column prop="info.NodeAddress" label="NodeAddress" width="240" align="center" />
                <el-table-column prop="info.OrgId" label="OrgId" width="250" align="center" />
                <el-table-column prop="info.TlsHostName" label="TlsHostName" align="center" />
                <!-- <el-table-column prop="sign" label="sign" /> -->
                <el-table-column prop="name" label="操作" width="200" align="center">
                    <template slot-scope="scope">
                        <!-- <el-button type="primary" plain @click="deleteChain(scope.$index)">移除</el-button> -->
                        <!-- <el-button type="primary" plain @click="updateChainShow(scope.$index)">更新</el-button> -->
                        <el-button type="primary" plain @click="signChainShow(scope.$index)">签名</el-button>
                        <el-button type="primary" plain @click="bindChainShow(scope.$index)">绑定</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <el-dialog title="对业务链DID进行签名" :visible.sync="signChainVisible">
                <el-form :model="signForm">
                    <el-form-item label="privateKey" :label-width="formLabelWidth">
                        <el-input v-model="signForm.privateKey" autocomplete="off" type="textarea"></el-input>
                    </el-form-item>
                    <el-form-item label="DID" :label-width="formLabelWidth">
                        <el-input v-model="signForm.message" autocomplete="off"></el-input>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="cancelSignChain()">取 消</el-button>
                    <el-button type="primary" @click="signChain()">确 定</el-button>
                </div>
            </el-dialog>
            <el-dialog title="对业务链进行绑定" :visible.sync="bindChainVisible">
                <el-form :model="bindForm">
                    <el-form-item label="rootDid" :label-width="formLabelWidth">
                        <el-input v-model="bindForm.rootDid" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="ChainDID" :label-width="formLabelWidth">
                        <el-input v-model="bindForm.ChainDID" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="Sign" :label-width="formLabelWidth">
                        <el-input v-model="bindForm.sign" autocomplete="off" type="textarea"></el-input>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="cancelBindChain()">取 消</el-button>
                    <el-button type="primary" @click="bindChain()">确 定</el-button>
                </div>
            </el-dialog>
        </div>
        <div class="root-list">
            <div style="display: flex; margin-bottom: 10px;">
                <div style="padding-top: 4px;"><img src="@/assets/root.png" alt="" width="24px" height="24px"></div>
                <div class="root-title">root-did列表</div>
                <!-- <el-button type="primary" plain @click="addRootDidVisible = true">注册root-did</el-button> -->
            </div>
            <el-dialog title="注册root-did" :visible.sync="addRootDidVisible">
                <el-form :model="rootDidForm">
                    <el-form-item label="rootDid" :label-width="formLabelWidth">
                        <el-input v-model="rootDidForm.rootDid" autocomplete="off"></el-input>
                    </el-form-item>
                    <el-form-item label="pubkey" :label-width="formLabelWidth">
                        <el-input v-model="rootDidForm.pubkey" autocomplete="off"  type="textarea"></el-input>
                    </el-form-item>
                </el-form>
                <div slot="footer" class="dialog-footer">
                    <el-button @click="cancelAddRootDid()">取 消</el-button>
                    <el-button type="primary" @click="addRootDid()">确 定</el-button>
                </div>
            </el-dialog>
            <el-table :data="rootData" v-loading="loading" :border="true" style="width: 40%" :header-cell-style="{background:'#D8E8FF'}">
                <el-table-column type="index" label="序号" width="80" align="center" />
                <el-table-column prop="rootDid" label="rootDid" align="center" />
            </el-table>
        </div>
        <div class="verify">
            <div style="display: flex; margin-bottom: 15px;">
                <div style="padding-top: 6px;"><img src="@/assets/check.png" alt="" width="20px" height="20px"></div>
                <div class="verify-title">用户sm9vc校验</div>
                <el-button type="primary" plain @click="verify()">校验</el-button>
            </div>
            <div>
                <el-row>
                    <el-col :span="20" style="font-size: 14px;">
                        <el-row style="margin-bottom: 10px;">
                            <el-col :span="2" style="padding-left: 50px;">key</el-col>
                            <el-col :span="22"><el-input placeholder="请输入key" v-model="key" clearable type="textarea" :rows="1" /></el-col>
                        </el-row>
                        <el-row style="margin-bottom: 10px;">
                            <el-col :span="2" style="padding-left: 50px;">auth</el-col>
                            <el-col :span="9"><el-input placeholder="请输入auth" v-model="auth" clearable /></el-col>
                            <el-col :span="2">chainDID</el-col>
                            <el-col :span="11"><el-input placeholder="请输入chainDID" v-model="chainDID" clearable type="textarea" :rows="1" /></el-col>
                        </el-row>
                        <el-row>
                            <el-col :span="2" style="padding-left: 50px;">doc</el-col>
                            <el-col :span="9"><el-input placeholder="请输入doc" v-model="doc" clearable /></el-col>
                            <el-col :span="2">signature</el-col>
                            <el-col :span="11"><el-input placeholder="请输入signature" v-model="signature" clearable type="textarea" :rows="1" /></el-col>
                        </el-row>
                    </el-col>
                    <el-col :span="4">
                        <div v-if="this.verifyFlag == 0" style="padding: 40px 0 0 100px; font-size: 26px; display: flex; line-height: 40px;">
                            <img src="@/assets/error.png" alt="" width="40px" height="40px">
                        </div>
                        <div v-if="this.verifyFlag == 1" style="padding: 40px 0 0 100px; font-size: 26px; display: flex; line-height: 40px;">
                            <img src="@/assets/success.png" alt="" width="40px" height="40px">
                        </div>
                    </el-col>
                </el-row>
                
                
                
                
            </div>
        </div>
        <div class="aggregation">
            <div style="display: flex; margin-bottom: 15px;">
                <div style="padding-top: 6px;"><img src="@/assets/get.png" alt="" width="20px" height="20px"></div>
                <div class="aggregation-title">聚合vc</div>
                <el-button type="primary" plain @click="createVisible = true; verifyVisible = false">生成聚合vc</el-button>
                <el-button type="primary" plain @click="createVisible = false; verifyVisible = true">校验聚合vc</el-button>
            </div>
            <div v-if="createVisible">
                <div v-for="(d, index) in createAVCForm" :key="index">
                    <div style="font-size: 16px; font-weight: 600; margin: 5px 0 15px 50px;">
                        <i class="el-icon-delete" style="color: #1196db; cursor: pointer;" v-if="index != 0" @click="deleteACVForm(index)"></i>
                        业务链{{index+1}}：
                    </div>
                    <el-row style="margin-bottom: 10px;">
                        <el-col :span="20" style="font-size: 14px;">
                            <el-row style="margin-bottom: 10px;">
                                <el-col :span="2" style="padding-left: 50px;">key</el-col>
                                <el-col :span="22"><el-input placeholder="请输入key" v-model="d.key" clearable type="textarea" :rows="1" /></el-col>
                            </el-row>
                            <el-row style="margin-bottom: 10px;">
                                <el-col :span="2" style="padding-left: 50px;">auth</el-col>
                                <el-col :span="9"><el-input placeholder="请输入auth" v-model="d.auth" clearable /></el-col>
                                <el-col :span="2">chainDID</el-col>
                                <el-col :span="11"><el-input placeholder="请输入chainDID" v-model="d.chainDID" clearable type="textarea" :rows="1" /></el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="2" style="padding-left: 50px;">doc</el-col>
                                <el-col :span="9"><el-input placeholder="请输入doc" v-model="d.doc" clearable /></el-col>
                                <el-col :span="2">signature</el-col>
                                <el-col :span="11"><el-input placeholder="请输入signature" v-model="d.signature" clearable type="textarea" :rows="1" /></el-col>
                            </el-row>
                        </el-col>
                    </el-row>
                </div>
                <el-button type="primary" plain @click="addAVCForm()" style="margin-left: 60px;">添加</el-button>
                <el-button type="primary" plain @click="createAVC()">生成</el-button>
                <div style="font-size: 14px; margin: 10px 0 0 60px;">{{ this.AVC }}</div>
            </div>
            <div v-if="verifyVisible">
                <el-row style="margin-bottom: 10px; font-size: 14px;">
                    <el-col :span="2" style="padding-left: 50px;">signature</el-col>
                    <el-col :span="9"><el-input placeholder="请输入signature" v-model="verifySignature" clearable /></el-col>
                </el-row>
                <div v-for="(d, index) in verifyAVCForm" :key="index">
                    <div style="font-size: 16px; font-weight: 600; margin: 5px 0 15px 50px;">
                        <i class="el-icon-delete" style="color: #1196db; cursor: pointer;" v-if="index != 0" @click="deleteVerfyForm(index)"></i>
                        业务链{{index+1}}：
                    </div>
                    <el-row style="margin-bottom: 10px;">
                        <el-col :span="20" style="font-size: 14px;">
                            <el-row style="margin-bottom: 10px;">
                                <el-col :span="2" style="padding-left: 50px;">auth</el-col>
                                <el-col :span="9"><el-input placeholder="请输入auth" v-model="d.auth" clearable /></el-col>
                                <el-col :span="2">chainDID</el-col>
                                <el-col :span="11"><el-input placeholder="请输入chainDID" v-model="d.chainDID" clearable type="textarea" :rows="1" /></el-col>
                            </el-row>
                            <el-row>
                                <el-col :span="2" style="padding-left: 50px;">doc</el-col>
                                <el-col :span="9"><el-input placeholder="请输入doc" v-model="d.doc" clearable /></el-col>
                                <el-col :span="2">key</el-col>
                                <el-col :span="11"><el-input placeholder="请输入key" v-model="d.key" clearable type="textarea" :rows="1" /></el-col>
                            </el-row>
                        </el-col>
                    </el-row>
                </div>
                <el-button type="primary" plain @click="addVerifyForm()" style="margin-left: 60px;">添加</el-button>
                <el-button type="primary" plain @click="verifyAVC()">校验</el-button>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data() {
        return {
            addChainVisible: false,
            addUserChainVisible: false,
            updateChainVisible: false,
            addRootDidVisible: false,
            signChainVisible: false,
            bindChainVisible: false,
            chainForm: {           
                issuerDid: '',
                tlsHostName: '',
                nodeAddress: '',
                chainId: '',
                orgId: '',
                certificates: {
                    rootCaCrt: '',
                    userKey: '',
                    userCrt: '',
                    userSignKey: '',
                    userSignCrt: '',
                }
            },
            userChainForm: {           
                issuerDid: '',
                tlsHostName: '',
                nodeAddress: '',
                chainId: '',
                orgId: '',
                certificates: {
                    rootCaCrt: '',
                    userKey: '',
                    userCrt: '',
                    userSignKey: '',
                    userSignCrt: '',
                }
            },
            rootDidForm: {           
                rootDid: '',
                pubkey: '',
            },
            signForm: {           
                privateKey: '',
                message: '',
            },
            bindForm: {           
                rootDid: '',
                ChainDID: '',
                sign: '',
            },
            formLabelWidth: '120px',
            tableData: [
                {
                    "ChainDID": "did:ctid:1EuEiRBBtuiWJcPh76CfnVVxvnt9zE1rnp",
                    "info": {
                        "ChainId": "chain_dcwjm",
                        "NodeAddress": "36.110.223.84:9000",
                        "OrgId": "69vkhhkorg.cm-048rqsevp9",
                        "TlsHostName": "consensus1-69vkhhkorg.cm-048rqsevp9"
                    },
                    "sign": []
                },
                {
                    "ChainDID": "did:ctid:1EuEiRBBtuiWJcPh76CfnVVxvnt9zE1rnp",
                    "info": {
                        "ChainId": "chain_ctrch",
                        "NodeAddress": "36.110.223.58:9000",
                        "OrgId": "70vtxxeorg.cm-054teDevt3",
                        "TlsHostName": "consensus1-70vtxxeorg.cm-054teDevt3"
                    },
                    "sign": []
                }
            ],
            userTableData: [
                {
                    "ChainDID": "did:ctid:1EuEiRBBtuiWJcPh76CfnVVxvnt9zE1rnp",
                    "info": {
                        "ChainId": "chain_dcwjm",
                        "NodeAddress": "36.110.223.84:9000",
                        "OrgId": "69vkhhkorg.cm-048rqsevp9",
                        "TlsHostName": "consensus1-69vkhhkorg.cm-048rqsevp9"
                    },
                    "sign": []
                },
                {
                    "ChainDID": "did:ctid:27DwsjpH1TvTgbPdRWfRNsjoMsxF93ma5R",
                    "info": {
                        "ChainId": "chain_dcwjm",
                        "NodeAddress": "36.110.223.58:9000",
                        "OrgId": "70vtxxeorg.cm-054teDevt3",
                        "TlsHostName": "consensus1-70vtxxeorg.cm-054teDevt3"
                    },
                    "sign": []
                },
                // {
                //     "ChainDID": "did:ctid:25s8K9ZTDfLK25HwXiaNNUTczoeMycfchr",
                //     "info": {
                //         "ChainId": "chain_ctrch",
                //         "NodeAddress": "36.110.222.84:9000",
                //         "OrgId": "73ectecorg.cm-057trfrty8",
                //         "TlsHostName": "consensus1-73ectecorg.cm-057trfrty8"
                //     },
                //     "sign": []
                // }
                
            ],
            updateChainIndex: 0,
            signChainIndex: 0,
            bindChainIndex: 0,
            rootDidParams: '',
            rootData: [
                {
                    "rootDid": "did:ctid:2z3kQEC6AKDwJsVk889RwARbyfuSefFmN8",
                    "pubkey": "",
                    "privateKey": "-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgkRjRlkNlLCWP7uJq\ng/OPtpbKO8cN8MYFKmKiNwr3+ZagCgYIKoEcz1UBgi2hRANCAARdE1bthn4gTOqE\nPh1hyEgG/rrj+aAtqZd7kae7WAwpni8BIhNMbOqbvGQcbCF/rSGE5q7utTGc3tTN\n8pXyH4ik\n-----END PRIVATE KEY-----\n",
                    "bindList": []
                },
                {
                    "rootDid": "did:ctid:28s1t9xtvLK25Hwsdje2NNUTczoeMycfDf8",
                    "pubkey": "",
                    "privateKey": "-----BEGIN PRIVATE KEY-----\nzddWZJUjghyGdByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgkRjRlkNlLCWP7uJq\ng/OPtpbKO8cN8MYFKmKiNwr3+ZagCgYIKoEcz1UBgi2hRANCAARdE1bthn4gTOqE\nPh1hyEgG/rrj+aAtqZd7kae7WAwpni8BIhNMbOqbvGQcbCF/rSGE5q7utTGc3tTN\n8pXyH4ik\n-----END PRIVATE KEY-----\n",
                    "bindList": []
                },
                {
                    "rootDid": "did:ctid:27Dwsxpf12vxrDdzrWfRNsjoMsxF93mA5y",
                    "pubkey": "",
                    "privateKey": "-----BEGIN PRIVATE KEY-----\nDaDtcGeaMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgkRjRlkNlLCWP7uJq\ng/OPtpbKO8cN8MYFKmKiNwr3+ZagCgYIKoEcz1UBgi2hRANCAARdE1bthn4gTOqE\nPh1hyEgG/rrj+aAtqZd7kae7WAwpni8BIhNMbOqbvGQcbCF/rSGE5q7utTGc3tTN\n8pXyH4ik\n-----END PRIVATE KEY-----\n",
                    "bindList": []
                }
            ],
            bindList: [],
            chain1: "",
            chain2: "",
            affirmFlag: -1,
            signature: "",
            doc: "",
            auth: "",
            chainDID: "",
            key: "",
            verifyFlag: -1,
            createAVCForm: [
                {
                    signature: "",
                    doc: "",
                    auth: "",
                    chainDID: "",
                    key: "",
                },
            ],
            verifySignature: "",
            verifyAVCForm: [
                {
                    doc: "",
                    auth: "",
                    chainDID: "",
                    key: "",
                },
            ],
            AVC: "",
            createVisible: true,
            verifyVisible: false,
            AVCNumber: 0,
            verifyData: [
                {
                    "ChainDID": "did:ctid:1EuEiRBBtuiWJcPh76CfnVVxvnt9zE1rnp",
                    "signature": "etvo2HBHnkY1qWkzFHbNiczCBRWC4oZBFfOvRbzjYA6rVSkThau6zdJY6O22j7U1-27XW3KsCK9IXJSvsI2zPhIQINFAglbEwfcyFOIv8Q4REQRPKWkg0LHkGinIrftgs",
                    "auth": "asd",
                    "key": "VWYkfwAAAABCnTKEAAAAABksxdsAAAAAnRUs6gAAAAAdTTRYAAAAAAI9o3EAAAAA2ifKQQAAAABv2dQPAAAAAM77/ogAAAAAJ/RZZQAAAAAGBMcLAAAAANGrjV0AAAAA9v6/LQAAAAC4e0RyAAAAAJD6/6YAAAAAqdbTWAAAAAD+mEMOAAAAAGSc8pQAAAAA4u6/dQAAAAD6G/13AAAAAFLJySEAAAAAB/J9fAAAAAC5O8KCAAAAAKebG0QAAAAAcRlZHgAAAADJYsxMAAAAANZnqtAAAAAArxB19wAAAABZj8ZhAAAAALRv89oAAAAAtKm/oAAAAABK+P99AAAAAKWBcaoAAAAA8C3d8AAAAADMABBoAAAAACnOutYAAAAATZ9q5gAAAAAnRd6MAAAAAEf94gMAAAAATQhlpAAAAADhXOjTAAAAAKkk3fsAAAAA6p4K6AAAAABWJgVLAAAAAMtTxR8AAAAAzFrwIgAAAADA5OizAAAAAEEqhWcAAAAAO9uAKAAAAACMjErUAAAAAAPO0HQAAAAA4SslqAAAAABAstbYAAAAAPwhCVwAAAAAgpE3+wAAAABMKG1LAAAAAA==",
                    "doc": "dsa"
                },
                {
                    "ChainDID": "did:ctid:27DwsjpH1TvTgbPdRWfRNsjoMsxF93ma5R",
                    "signature": "oV3gwWFOOEG8Y4110lgkIWk8UC4sD3xh0FFxvKO9hIy6W1IzLuRZCC4aFGXnP8E5-pJMXC9N3G8bzXMYuwQV0TKDdoLzhKmFgLksITQwiXkStYQX2TKXxgOwfZck6dYCm",
                    "auth": "asd",
                    "key": "pU2JsAAAAACCYHgxAAAAAC2eq6gAAAAA37zZMAAAAACTjRk7AAAAAN/32o4AAAAAjeuD9wAAAADHoJU/AAAAAAh8ykMAAAAAsscC4wAAAADioAQHAAAAABK5dsoAAAAABDm9jAAAAADv5zrDAAAAANzk+NgAAAAAjfx+bQAAAAAIfbgFAAAAAMRZnvAAAAAA29omRQAAAABNDi0CAAAAAB6Z0OEAAAAAttYwrQAAAACP27FlAAAAAJU3F60AAAAAsSLwKQAAAADALDjTAAAAAJf7DCUAAAAAgGemTwAAAAAfErOXAAAAADuCFuYAAAAAgqzG8QAAAADto8CHAAAAAANDrPcAAAAAFNQLqwAAAADNQVw2AAAAAAapNOEAAAAAVCImjAAAAADHCozMAAAAAJIKrfwAAAAAFxMkcQAAAAD8NnSaAAAAAHNoTa4AAAAAYZzv9AAAAABpEDEtAAAAAMSQ6JQAAAAAwG74dwAAAABD9gkoAAAAAFJK0zwAAAAAdL5SQAAAAABPz7umAAAAACU0KJIAAAAATSfKRgAAAADTrJMnAAAAAKewc1oAAAAArmoqcwAAAABaX4cVAAAAAA==",
                    "doc": "dsa"
                },
                {
                    "ChainDID": "did:ctid:25s8K9ZTDfLK25HwXiaNNUTczoeMycfchr",
                    "signature": "abfc655eb14dedf133bf4f0df4902a14764c036b117b774458c624dbc2e3be3b-574a490d7f5db4abd50d111ddc5968acbb240ee5991182a23db49a0d89ed9f02",
                    "auth": "asd",
                    "key": "no+9YAAAAABOA0TJAAAAAGz7iEAAAAAAIzldVgAAAABe6iNgAAAAAIgc8Y4AAAAA8LEcCQAAAAAF5ys+AAAAANiwgkAAAAAAtqJrLgAAAACLcY0tAAAAANV8k64AAAAAV4UqsAAAAAC0hkbwAAAAAHlqzl4AAAAAGI4PMwAAAABWDLqZAAAAAIoGYEwAAAAAmLs34wAAAACZSMJIAAAAAJVOLkoAAAAAW5BuXgAAAABuZ2CvAAAAAKr3NKQAAAAAAu3koQAAAAB2+CzUAAAAAHls6yEAAAAAP2Sy4wAAAAC1C7HcAAAAAAsR5IIAAAAAxRuexQAAAADxSIJlAAAAABY3rWYAAAAAJU7oPAAAAAAuoSvvAAAAAGTrshgAAAAA5p6ITwAAAAClHUFmAAAAAPH7ho8AAAAAjy8fEQAAAAAbBOmpAAAAAFXMOwAAAAAAH/lIogAAAAA2mqMpAAAAAGP2WTcAAAAAFwRZ8gAAAAAQUIcNAAAAACeW2ogAAAAAWiHpWQAAAAC5F6VeAAAAAL7rm9oAAAAA4qaGPwAAAACV0DaxAAAAAOowOhQAAAAALqkefAAAAAChbHqPAAAAAA==",
                    "doc": "dsa"
                },
            ],
            
        }
    },
    methods: {
        clearChainForm() {
            this.chainForm = {           
                issuerDid: '',
                tlsHostName: '',
                nodeAddress: '',
                chainId: '',
                orgId: '',
                certificates: {
                    rootCaCrt: '',
                    userKey: '',
                    userCrt: '',
                    userSignKey: '',
                    userSignCrt: '',
                }
            }
        },
        clearUserChainForm() {
            this.userChainForm = {           
                issuerDid: '',
                tlsHostName: '',
                nodeAddress: '',
                chainId: '',
                orgId: '',
                certificates: {
                    rootCaCrt: '',
                    userKey: '',
                    userCrt: '',
                    userSignKey: '',
                    userSignCrt: '',
                }
            }
        },
        clearRootDidForm() {
            this.rootDidForm = {           
                rootDid: '',
                pubkey: '',
            }
        },
        clearSignForm() {
            this.signForm = {           
                privateKey: '',
                message: '',
            }
        },
        clearBindForm() {
            this.bindForm = {           
                rootDid: '',
                ChainDID: '',
                sign: '',
            }
        },
        addChain() {
            console.log(111)
            var info = {
                "ChainDID": this.chainForm.issuerDid,
                "info": {
                    "ChainId": this.chainForm.chainId,
                    "NodeAddress": this.chainForm.nodeAddress,
                    "OrgId": this.chainForm.orgId,
                    "TlsHostName": this.chainForm.tlsHostName
                },
                "sign": []
            }
            this.tableData.push(info)
            this.addChainVisible = false
            this.$message.success('添加业务链成功');
            this.clearChainForm()
        },
        addUserChain() {
            var info = {
                "ChainDID": this.userChainForm.issuerDid,
                "info": {
                    "ChainId": this.userChainForm.chainId,
                    "NodeAddress": this.userChainForm.nodeAddress,
                    "OrgId": this.userChainForm.orgId,
                    "TlsHostName": this.userChainForm.tlsHostName
                },
                "sign": []
            }
            this.userTableData.push(info)
            console.log(this.userTableData)

            this.addUserChainVisible = false
            this.$message.success('添加业务链成功');
            this.clearUserChainForm()
        },
        cancelAddChain() {
            this.addChainVisible = false
            this.clearChainForm()
        },
        cancelUserAddChain() {
            this.addUserChainVisible = false
            this.clearUserChainForm()
        },
        deleteChain(index) {
            this.tableData.splice(index, 1)
            this.addChainVisible = false
            this.$message.success('移除业务链成功');
        },
        updateChain() {
            this.tableData[this.updateChainIndex].ChainDID = this.chainForm.issuerDid
            this.tableData[this.updateChainIndex].info.TlsHostName = this.chainForm.tlsHostName
            this.tableData[this.updateChainIndex].info.NodeAddress = this.chainForm.nodeAddress
            this.tableData[this.updateChainIndex].info.ChainId = this.chainForm.chainId
            this.tableData[this.updateChainIndex].info.OrgId = this.chainForm.orgId
            this.updateChainVisible = false
            this.$message.success('更新业务链信息成功');
            this.clearChainForm()
        },
        updateChainShow(index) {
            this.chainForm.issuerDid = this.tableData[index].ChainDID
            this.chainForm.tlsHostName = this.tableData[index].info.TlsHostName
            this.chainForm.nodeAddress = this.tableData[index].info.NodeAddress
            this.chainForm.chainId = this.tableData[index].info.ChainId
            this.chainForm.orgId = this.tableData[index].info.OrgId
            this.chainForm.rootCaCrt = "-----BEGIN CERTIFICATE-----\nMIICcTCCAhegAwIBAgIDAPh6MAoGCCqBHM9VAYN1MGkxCzAJBgNVBAYTAkNOMRAw\nDgYDVQQIEwdCZWlqaW5nMRAwDgYDVQQHEwdCZWlqaW5nMRAwDgYDVQQKEwd3eC1y\nb290MQ0wCwYDVQQLEwRyb290MRUwEwYDVQQDEwxyb290Lnd4LXJvb3QwIBcNMjMw\nNTE5MDMxNzE2WhgPMjEyMzA0MjUwMzE3MTZaMIGGMQ4wDAYDVQQGEwVjaGluYTEO\nMAwGA1UECBMFY2hpbmExDjAMBgNVBAcTBWNoaW5hMSEwHwYDVQQKExg2OXZraGhr\nb3JnLmNtLTA0OHJxc2V2cDkxCzAJBgNVBAsTAmNhMSQwIgYDVQQDExtjYS42OXZr\naGhrb3JnLmNtLTA0OHJxc2V2cDkwWTATBgcqhkjOPQIBBggqgRzPVQGCLQNCAATO\nZgWsGDkUkqkXNFdfKIUwrMfoocehXBF8A3IJLDFzYgJAY2ltScrMUUXMTNGPTydM\n0IhZ0olAmU8Lbs4IpolAo4GNMIGKMA4GA1UdDwEB/wQEAwIBpjAPBgNVHSUECDAG\nBgRVHSUAMA8GA1UdEwEB/wQFMAMBAf8wKQYDVR0OBCIEIFFvqGprwNf4al9CgOFT\nU6EW+SfNfmkdRfN2y4op7qIfMCsGA1UdIwQkMCKAIO4KLUzkcvD2jHU35Z5zurHU\nkYBz2d6S8yPw7wKvmFVlMAoGCCqBHM9VAYN1A0gAMEUCIQDQNtD8oNgJwz+0qgiL\nY5fQhQDd0Ld8kPHnb6zF8u19WwIgG6OuM27aeetO/vlLK0Tjg+0DyN4VAJnVyYqb\ntd4Vh4E=\n-----END CERTIFICATE-----\n"
            this.chainForm.userKey = "-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQguV4zEu+xnBpxRSy6\nNt29yYTOYPIMNdAyssuR4WtVIGGgCgYIKoEcz1UBgi2hRANCAAQGRnq3stju5w0W\nWYhdv8zlXLy0A+WbQeXyBw9FjdHU+1uVDHzP/52JjzeToafGAyI4Phck1fYDihYL\nq+yxV4cf\n-----END PRIVATE KEY-----\n"
            this.chainForm.userCrt = "-----BEGIN CERTIFICATE-----\nMIICgTCCAiegAwIBAgIDCpkhMAoGCCqBHM9VAYN1MIGGMQ4wDAYDVQQGEwVjaGlu\nYTEOMAwGA1UECBMFY2hpbmExDjAMBgNVBAcTBWNoaW5hMSEwHwYDVQQKExg2OXZr\naGhrb3JnLmNtLTA0OHJxc2V2cDkxCzAJBgNVBAsTAmNhMSQwIgYDVQQDExtjYS42\nOXZraGhrb3JnLmNtLTA0OHJxc2V2cDkwHhcNMjMwNTE5MDMxNzQwWhcNMjgwNTE3\nMDMxNzQwWjCBjTEOMAwGA1UEBhMFY2hpbmExDjAMBgNVBAgTBWNoaW5hMQ4wDAYD\nVQQHEwVjaGluYTEhMB8GA1UEChMYNjl2a2hoa29yZy5jbS0wNDhycXNldnA5MQ4w\nDAYDVQQLEwVhZG1pbjEoMCYGA1UEAxMfeWd6Yzg2LjY5dmtoaGtvcmcuY20tMDQ4\ncnFzZXZwOTBZMBMGByqGSM49AgEGCCqBHM9VAYItA0IABAZGerey2O7nDRZZiF2/\nzOVcvLQD5ZtB5fIHD0WN0dT7W5UMfM//nYmPN5Ohp8YDIjg+FyTV9gOKFgur7LFX\nhx+jezB5MA4GA1UdDwEB/wQEAwIBpjAPBgNVHSUECDAGBgRVHSUAMCkGA1UdDgQi\nBCDo5yyoriEgejHtkdYC21vJDa/2wY5skyKGKkWvzqOvQTArBgNVHSMEJDAigCBR\nb6hqa8DX+GpfQoDhU1OhFvknzX5pHUXzdsuKKe6iHzAKBggqgRzPVQGDdQNIADBF\nAiEAvHQ6mNEC4P6OhsrZsDX4BHZhPO8jEvD3akCpHkh0o8UCIDFkfWQr6akf+/kn\nkxo/XDE8nq0w/F140UFPN8QENxpT\n-----END CERTIFICATE-----\n"
            this.chainForm.userSignKey = "-----BEGIN PRIVATE KEY-----\nMIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQggC0LQaHUkVOUko3f\npP7mw2IUFbgUYZIIHsozn7pQcpygCgYIKoEcz1UBgi2hRANCAASwyLtWVuQImLPU\n48dNjpGBYg7jzBuhXGPyAuthHHObUYRQ+OWVX8ClR6uFTkfGSS3nCaWXCcut+Nf5\n1Bo/tya+\n-----END PRIVATE KEY-----\n"
            this.chainForm.userSignCrt = "-----BEGIN CERTIFICATE-----\nMIICgjCCAiegAwIBAgIDDjnvMAoGCCqBHM9VAYN1MIGGMQ4wDAYDVQQGEwVjaGlu\nYTEOMAwGA1UECBMFY2hpbmExDjAMBgNVBAcTBWNoaW5hMSEwHwYDVQQKExg2OXZr\naGhrb3JnLmNtLTA0OHJxc2V2cDkxCzAJBgNVBAsTAmNhMSQwIgYDVQQDExtjYS42\nOXZraGhrb3JnLmNtLTA0OHJxc2V2cDkwHhcNMjMwNTE5MDMxNzQwWhcNMjgwNTE3\nMDMxNzQwWjCBjTEOMAwGA1UEBhMFY2hpbmExDjAMBgNVBAgTBWNoaW5hMQ4wDAYD\nVQQHEwVjaGluYTEhMB8GA1UEChMYNjl2a2hoa29yZy5jbS0wNDhycXNldnA5MQ4w\nDAYDVQQLEwVhZG1pbjEoMCYGA1UEAxMfeWd6Yzg2LjY5dmtoaGtvcmcuY20tMDQ4\ncnFzZXZwOTBZMBMGByqGSM49AgEGCCqBHM9VAYItA0IABLDIu1ZW5AiYs9Tjx02O\nkYFiDuPMG6FcY/IC62Ecc5tRhFD45ZVfwKVHq4VOR8ZJLecJpZcJy6341/nUGj+3\nJr6jezB5MA4GA1UdDwEB/wQEAwIBpjAPBgNVHSUECDAGBgRVHSUAMCkGA1UdDgQi\nBCAjsTHWx4l+yWlxlUf0K+l6Va6l7opteymLN1Qjj+L5VzArBgNVHSMEJDAigCBR\nb6hqa8DX+GpfQoDhU1OhFvknzX5pHUXzdsuKKe6iHzAKBggqgRzPVQGDdQNJADBG\nAiEAoW5iOSR7p+2L4FTc7x4rMiqvMWH4hCeyLgu9nv9IFtkCIQDleChubAvhovNX\nhpgZp3En8CV5t+MeEEm60o0i2bjGUQ==\n-----END CERTIFICATE-----\n"
            this.updateChainVisible = true
            this.updateChainIndex = index
        },
        addRootDid() {
            const characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
            const signLength = "MIGTAgEAMBMGByqGSM49AgEGCCqBHM9VAYItBHkwdwIBAQQgkRjRlkNlLCWP7uJq".length
            let randomSign = ''
            for (let i = 0; i < signLength; i++) {
                const randomIndex = Math.floor(Math.random() * characters.length)
                randomSign += characters.charAt(randomIndex)
            }
            var info = {
                "rootDid": this.rootDidForm.rootDid,
                "pubkey": this.rootDidForm.pubkey,
                "privateKey": "-----BEGIN PRIVATE KEY-----\n"+randomSign+"\ng/OPtpbKO8cN8MYFKmKiNwr3+ZagCgYIKoEcz1UBgi2hRANCAARdE1bthn4gTOqE\nPh1hyEgG/rrj+aAtqZd7kae7WAwpni8BIhNMbOqbvGQcbCF/rSGE5q7utTGc3tTN\n8pXyH4ik\n-----END PRIVATE KEY-----\n",
                "bindList": []
            }
            this.rootData.push(info)
            this.addRootDidVisible = false
            this.clearRootDidForm()
            console.log(this.rootData)
        },
        cancelAddRootDid() {
            this.addRootDidVisible = false
            this.clearRootDidForm()
        },
        signChainShow(index) {
            this.signChainVisible = true
            this.signChainIndex = index
            this.signForm.message = this.userTableData[this.signChainIndex].ChainDID
        },
        signChain() {
            this.signChainVisible = false
            const characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
            const signLength = 100
            let randomSign = ''
            for (let i = 0; i < signLength; i++) {
                const randomIndex = Math.floor(Math.random() * characters.length)
                randomSign += characters.charAt(randomIndex)
            }
            var info = {
                "privateKey": this.signForm.privateKey,
                "sign": randomSign,
            }
            this.userTableData[this.signChainIndex].sign.push(info)
            console.log(this.userTableData)
            this.$message.success('签名成功');
            this.clearSignForm()
        },
        cancelSignChain() {
            this.signChainVisible = false
            this.clearSignForm()
        },
        bindChainShow(index) {
            this.bindForm.ChainDID = this.userTableData[index].ChainDID
            this.bindChainVisible = true
            this.bindChainIndex = index
        },
        cancelBindChain() {
            this.bindChainVisible = false
            this.clearBindForm()
        },
        bindChain() {
            let flag = false
            this.bindChainVisible = false
            var info = {
                "rootDid": this.bindForm.rootDid,
                "ChainDID": this.bindForm.ChainDID,
                "sign": this.bindForm.sign,
            }
            for(let i = 0; i < this.rootData.length; i++) {
                console.log(this.bindForm.rootDid)
                console.log(this.rootData[i].rootDid)

                if (this.bindForm.rootDid == this.rootData[i].rootDid) {
                    console.log(222)
                    let j = 0
                    for(; j < this.userTableData[this.bindChainIndex].sign.length; j++) {
                        if (this.userTableData[this.bindChainIndex].sign[j].sign == this.bindForm.sign) {
                            console.log(333)
                            break
                        }
                    }
                    console.log(j)
                    if (j < this.userTableData[this.bindChainIndex].sign.length) {
                        console.log(this.userTableData[this.bindChainIndex].sign[j])
                        console.log(this.rootData[i])
                        console.log(this.userTableData[this.bindChainIndex].sign[j].privateKey == this.rootData[i].privateKey)
                        if (this.userTableData[this.bindChainIndex].sign[j].privateKey == this.rootData[i].privateKey) {
                            console.log(11111)
                            this.rootData[i].bindList.push(info)
                            this.$message.success('绑定成功');
                            flag = true
                            break
                        }
                        console.log(flag)
                    }
                }
            }
            if (flag == false) {
                this.$message.success('绑定失败，请检查');
            }
            console.log(this.rootData)
            this.clearBindForm()
        },
        showBindList() {
            let i = 0
            for(; i < this.rootData.length; i++) {
                if (this.rootDidParams == this.rootData[i].rootDid) {
                    this.bindList = this.rootData[i].bindList
                    break
                }
            }
            if (i == this.rootData.length) {
                this.bindList = []
            }
        },
        affirm() {
            let i =0
            for(; i < this.bindList.length; i++) {
                if (this.chain1 == this.bindList[i].ChainDID) {
                    break
                }
            }
            if (i == this.bindList.length) {
                this.affirmFlag = 0
            } else {
                for(i = 0; i < this.bindList.length; i++) {
                if (this.chain2 == this.bindList[i].ChainDID) {
                    break
                }
            }
                if (i == this.bindList.length) {
                    this.affirmFlag = 0
                } else {
                    this.affirmFlag = 1
                }
            }
        },
        verify() {
            if (this.ChainDID == "" || this.doc == "" || this.auth == "" || this.signature == "" || this.key == "") {
                this.$message.error("请正确输入信息！")
                this.verifyFlag = -1
            } else {
                let i = 0
                this.verifyFlag = -1
                for (; i < this.verifyData.length; i++) {
                    let info = this.verifyData[i]
                    if (info.ChainDID == this.chainDID && info.signature == this.signature && info.auth == this.auth && info.key == this.key && info.doc == this.doc) {
                        this.verifyFlag = 1
                        break
                    }
                }
                if (this.verifyFlag == -1) {
                    this.verifyFlag = 0
                }
            }
        },
        addAVCForm() {
            let info = {
                signature: "",
                doc: "",
                auth: "",
                chainDID: "",
                key: "",
            }
            this.createAVCForm.push(info)
        },
        deleteACVForm(index) {
            this.createAVCForm.splice(index, 1)
        },
        createAVC() {
            let flag = true
            for (let i = 0; i < this.createAVCForm.length; i++) {
                let info = this.createAVCForm[i]
                if (info.chainDID != 0) {
                    console.log(111)
                    let j = 0;
                    for ( ; j < this.verifyData.length; j++) {
                        let table = this.verifyData[j]
                        if (info.chainDID == table.ChainDID && info.auth == table.auth && info.key == table.key && info.doc == table.doc && info.signature == table.signature ) {
                            // flag = false
                            // console.log("why")
                            console.log(info.signature != table.signature )
                            console.log(info.doc != table.doc)
                            console.log(info.key != table.key)
                            console.log(info.auth != table.auth)
                            console.log(info.chainDID != table.ChainDID )
                            break
                        }
                        console.log(222)
                    }
                    if (j == this.verifyData.length) {
                        flag = false
                    }
                } else {
                    flag = false
                }
                console.log(flag)
                if (flag == false) {
                    break
                }
                console.log(flag)
            }
            console.log(flag)
            if (flag == false) {
                this.$message.error("信息有误，生成聚合VC失败！")
            } else {
                this.$message.success("生成聚合VC成功！")
                const characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
                let signLength = "abfc655eb14dedf133bf4f0df4902a14764c036b117b774458c624dbc2e3be3b".length
                let randomSign = ''
                for (let i = 0; i < signLength; i++) {
                    const randomIndex = Math.floor(Math.random() * characters.length)
                    randomSign += characters.charAt(randomIndex)
                }
                this.AVC = randomSign + "-"
                signLength = "574a490d7f5db4abd50d111ddc5968acbb240ee5991182a23db49a0d89ed9f02".length
                randomSign = ''
                for (let i = 0; i < signLength; i++) {
                    const randomIndex = Math.floor(Math.random() * characters.length)
                    randomSign += characters.charAt(randomIndex)
                }
                this.AVC += randomSign
                this.AVCNumber = this.createAVCForm.length
            }
        },
        addVerifyForm() {
            let info = {
                doc: "",
                auth: "",
                chainDID: "",
                key: "",
            }
            this.verifyAVCForm.push(info)
        },
        deleteVerfyForm(index) {
            this.verifyAVCForm.splice(index, 1)
        },
        verifyAVC() {
            let flag = true
            for (let i = 0; i < this.verifyAVCForm.length; i++) {
                let info = this.verifyAVCForm[i]
                if (info.chainDID != 0) {
                    console.log(111)
                    let j = 0;
                    for ( ; j < this.verifyData.length; j++) {
                        console.log(j)
                        let table = this.verifyData[j]
                        if (info.chainDID == table.ChainDID && info.auth == table.auth && info.key == table.key && info.doc == table.doc ) {
                            // flag = false
                            // console.log("why")
                            // console.log(info.signature != table.signature )
                            // console.log(info.doc != table.certificate.doc)
                            // console.log(info.key != table.certificate.key)
                            // console.log(info.auth != table.certificate.auth)
                            // console.log(info.chainDID != table.ChainDID )
                            break
                        }
                        // console.log(222)
                    }
                    console.log(3)
                    if (j == this.verifyData.length) {
                        flag = false
                    }
                    console.log(flag)
                    console.log(i)
                } else {
                    flag = false
                }
                if (flag == false) {
                    break
                }
            }
            console.log(flag)
            console.log(this.AVC)
            console.log(this.verifySignature)

            if (flag == false || this.AVC != this.verifySignature || this.verifyAVCForm.length != this.AVCNumber) {
                this.$message.error("信息有误，校验聚合VC失败！")
            } else {
                this.$message.success("校验聚合VC成功！")
            }
        }


    }
}
</script>

<style lang="less" scoped>
.chain-list {
    padding: 20px 40px 30px 40px;
    .chain-title {
        font-size: 16px;
        font-weight: 600;
        line-height: 32px;
        margin: 0 10px;
    }
}
.user-chain-list {
    padding: 0px 40px 30px 40px;
    .user-chain-title {
        font-size: 16px;
        font-weight: 600;
        line-height: 32px;
        margin: 0 10px;
    }
}
.root-list {
    padding: 0px 40px 30px 40px;
    .root-title {
        font-size: 16px;
        font-weight: 600;
        line-height: 32px;
        margin: 0 10px;
    }
}
.verify {
    padding: 0 40px 30px 40px;
    .verify-title {
        font-size: 16px;
        font-weight: 600;
        line-height: 32px;
        margin: 0 10px;
    }
}
.aggregation {
    padding: 0 40px 30px 40px;
    .aggregation-title {
        font-size: 16px;
        font-weight: 600;
        line-height: 32px;
        margin: 0 10px;
    }
}
.identity {
    padding: 0px 40px 20px 40px;
    .identity-title {
        font-size: 16px;
        font-weight: 600;
        line-height: 32px;
        margin: 0 10px;
        height: 32px;
    }
}
.el-button{
  border-radius: 16px;
  font-size: 12px;
  padding: 9px 15px;
  &.el-button--primary.is-plain{
    color: #409EFF;
    background: #E9F2FF;
    border: 1px solid #C4E1FF;
  }
  &.el-button--danger.is-plain{
    color: #FF9D9D;
    background: #FDEEEE;
    border: 1px solid #FFD4D4;
  }
}
//表格内容颜色
::v-deep .el-table__body tbody tr:nth-child(odd) {
  background-color: #FFFFFF;
}
::v-deep .el-table__body tbody tr:nth-child(even) td {
  background-color: #F1F8FF;
}
//表头文字样式
::v-deep .el-table__header-wrapper {
  thead {
    th{
      div{
        font-weight: 500;
        font-size: 14px;
        color: #333333
      }
    }
  }
}
::v-deep {
    .el-input--suffix .el-input__inner {
        height: 32px;
        width: 400px;
    }
}

</style>